
//% color="#5180e6" iconWidth=50 iconHeight=40
    namespace jingyizhao{
        
    //% block="从路径:[TEXT]加载并安装翻译模型" blockType="command"
    //% TEXT.shadow="string" TEXT.defl=\translate-zh_en-1_9.argosmodel
    export function myBlock3(parameter: any, block: any) {
        let TEXT= parameter.TEXT.code
        Generator.addImport(`import argostranslate.package
import argostranslate.translate
import warnings`)
        Generator.addInit("myBlock5641",`warnings.filterwarnings("ignore", category=FutureWarning)`)
        Generator.addCode(`model_path = ${TEXT}
argostranslate.package.install_from_path(model_path)
installed_packages = argostranslate.package.get_installed_packages()`)
    }
    //% block="[TEXT1]译[TEXT2]模型文件是否安装成功？" blockType="boolean"
    //% TEXT1.shadow="limit" TEXT1.defl=zh
    //% TEXT2.shadow="limit" TEXT2.defl=en
    export function myBlock6(parameter: any, block: any) {
        let TEXT1= parameter.TEXT1.code
        let TEXT2= parameter.TEXT2.code
        Generator.addCode(`any(package.from_code == "${TEXT1}" and package.to_code == "${TEXT2}" for package in installed_packages)`)
    }
    //% block="设置待翻译语言:[TEXT1]，目标语言[TEXT2]" blockType="command"
    //% TEXT1.shadow="string" TEXT1.defl=zh
    //% TEXT2.shadow="string" TEXT2.defl=en
    export function myBlock7(parameter: any, block: any) {
        let TEXT1= parameter.TEXT1.code
        let TEXT2= parameter.TEXT2.code
        Generator.addInit("myBlock6011",`from_code = ${TEXT1}
to_code = ${TEXT2}`)
    }
    //% block="翻译[A]的结果" blockType="reporter"
    //% A.shadow="string" A.defl=你好
    export function myBlock8(parameter: any, block: any) {
        let A= parameter.A.code
        Generator.addCode(`argostranslate.translate.translate(${A}, from_code, to_code)`)
    }
    }
    